<template>
  <div :is="comp"></div>
</template>

<script>
import login from '@/views/login'
import menu from '@/views/menu'
import { getCache } from '@/util/storageUtils'
import { CTCE_USER_INFO } from '@/config/storageTypes'

export default {
  name: 'App',
  data () {
    return {
      comp: ''
    }
  },
  components: { login, menu },
  beforeCreate () {
    this.$notice.loading.show()
  },
  created () {
    getCache(CTCE_USER_INFO).then(res => {
      const user = JSON.parse(res)
      if (user) {
        this.$router.open({
          name: 'home',
          canBack: false,
          type: ''
        })
      } else {
        this.comp = 'login'
      }
      this.$nextTick(() => {
        this.$notice.loading.hide()
      })
    })
  }
}
</script>
